//聊天窗口
Ext.define('Logisticext.ui.ChatWindow', {
    extend: 'Ext.panel.Panel',
    width: 250,
    height: 400,
    title: '内部聊天',
    maximizable: true,
    modal: false,
    requires: [
        'Ext.data.TreeStore',
        'Ext.layout.container.Accordion',
        'Ext.toolbar.Spacer',
        'Ext.tree.Panel'
    ],
    initComponent: function() {
        var tree = Ext.create('Ext.tree.Panel', {
            title: '在线用户',
            rootVisible: false,
            lines: false,
            autoScroll: true,
            tools: [{
                    type: 'refresh',
                    handler: function(c, t) {
                        tree.setLoading(true, tree.body);
                        var root = tree.getRootNode();
                        root.collapseChildren(true, false);
                        Ext.Function.defer(function() { // mimic a server call
                            tree.setLoading(false);
                            root.expand(true, true);
                        }, 1000);
                    }
                }],
            store: Ext.create('Ext.data.TreeStore', {
                root: {
                    text: 'Online',
                    expanded: true,
                    children: [{
                            text: 'Friends',
                            expanded: true,
                            children: [
                                {text: 'Brian', iconCls: 'user', leaf: true},
                                {text: 'Kevin', iconCls: 'user', leaf: true},
                                {text: 'Mark', iconCls: 'user', leaf: true},
                                {text: 'Matt', iconCls: 'user', leaf: true},
                                {text: 'Michael', iconCls: 'user', leaf: true},
                                {text: 'Mike Jr', iconCls: 'user', leaf: true},
                                {text: 'Mike Sr', iconCls: 'user', leaf: true},
                                {text: 'JR', iconCls: 'user', leaf: true},
                                {text: 'Rich', iconCls: 'user', leaf: true},
                                {text: 'Nige', iconCls: 'user', leaf: true},
                                {text: 'Zac', iconCls: 'user', leaf: true}
                            ]
                        }, {
                            text: 'Family',
                            expanded: true,
                            children: [
                                {text: 'Kiana', iconCls: 'user-girl', leaf: true},
                                {text: 'Aubrey', iconCls: 'user-girl', leaf: true},
                                {text: 'Cale', iconCls: 'user-kid', leaf: true}
                            ]
                        }]
                }
            }),
            listeners: {
                itemdblclick: function(v, r) {
                    alert(r.get('text'));
                }
            }
        });
        Ext.apply(this, {
            animCollapse: false,
            //constrainHeader: true,
            layout: 'accordion',
            border: false,
            items: [
                tree,
                {
                    title: '所有用户',
                    html: '<p>Something useful would be in here.</p>',
                    autoScroll: true
                }
            ]
        });
        var win = this;
        this.callParent();
    }
});
